class Post < ActiveRecord::Base
  belongs_to :user
  belongs_to :blog
  has_attached_file :post_photo
  validates_attachment_size :post_photo, :less_than => 1.megabytes
#  validates_attachment_content_type :post_photo, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/gif']
  validates_format_of :widget, :with =>/<embed/,:message=>'รหัส Widget ไม่ถูกต้อง',
    :if=>Proc.new {|p| !p.widget.blank?}
end
